﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AuthorityMenuEdit.aspx.cs" Inherits="OpSystem.manage.authority.AuthorityMenuEdit" %>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <!-- #include file="~/include/header.html" -->
    <style>
        .form-horizontal .control-label {
            width: 15%;
            float: left;
            text-align: right;
        }

        .col-sm-3 {
            width: 80%;
            float: left;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server" class="form-horizontal">
        <section class="content">
            <div class="row">
                <div class="col-md-12">
                    <div class="box-body">

                        <div class="form-group">
                            <label for="name" class="col-sm-2 control-label">父级：</label>
                            <div class="col-sm-3">
                                <asp:DropDownList CssClass="form-control" Width="300px" ID="ddParentRole" runat="server"></asp:DropDownList>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="name">名称：</label>
                            <div class="col-sm-3">
                                <asp:TextBox CssClass="form-control" Width="300px" runat="server" MaxLength="16" ID="txtName" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="name">URL：</label>
                            <div class="col-sm-3">
                                <asp:TextBox CssClass="form-control" Width="300px" MaxLength="500" runat="server" ID="txtURL" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="name">代码：</label>
                            <div class="col-sm-3">
                                <asp:TextBox CssClass="form-control" Width="300px" runat="server" MaxLength="16" ID="txtMenuCode" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="name">排序：</label>
                            <div class="col-sm-3">
                                <asp:TextBox CssClass="form-control" Width="300px" runat="server" MaxLength="16" ID="txtOrderNum" />
                            </div>
                        </div>
                    </div>
                    <div class="box-footer text-center">
                        <asp:Button ID="btnSave" Text="确定" runat="server" OnClick="btnSave_Click" CssClass="btn btn-primary" />
                        <button type="button" onclick="BMCW.closeAll();" class="btn" id="cancel">取 消</button>
                        <input type="hidden" id="hidMenuId" value="<%=intID%>" />
                    </div>


                </div>

            </div>
            <!-- /.row -->
        </section>
    </form>
    <!-- #include file="~/include/footer.html" -->
    <script type="text/javascript">
        $(document).ready(function () {
            if ($("#hidMenuId").val() != "-1") {
                $("#txtMenuCode").focus();
            }

            $("#form1").bootstrapValidator({
                submitHandler: function (valiadtor, loginForm, submitButton) {
                    valiadtor.defaultSubmit();
                },
                fields: {
                    txtName: {
                        validators: {
                            notEmpty: {
                                message: '菜单名称不能为空'
                            },
                            stringLength: {
                                /*长度提示*/
                                min: 1,
                                max: 16,
                                message: '菜单名称长度必须在1到16之间'
                            }
                        }
                    },
                    txtURL: {
                        validators: {
                            notEmpty: {
                                message: 'URL不能为空'
                            },
                            stringLength: {
                                /*长度提示*/
                                min: 1,
                                max: 500,
                                message: 'URL长度必须在1到500之间'
                            }
                        }
                    },
                    txtOrderNum: {
                        validators: {
                            notEmpty: {
                                message: '排序不能为空'
                            },
                            digits: {
                                message: '排序只能是数字'
                            }
                        }
                    },
                    txtMenuCode: {
                        validators: {
                            notEmpty: {
                                message: '代码不能为空'
                            },
                            stringLength: {
                                /*长度提示*/
                                min: 1,
                                max: 12,
                                message: '代码长度必须在1到12之间'
                            },
                            callback: {
                                message: '代码重复',
                                callback: function (value, validator, $field) {
                                    var bol = true;
                                    $.ajax({
                                        url: '../ajax/api.aspx',
                                        type: 'POST',
                                        async: false,
                                        dataType: "json",
                                        data: {
                                            action: "checkCode",
                                            code: function () { return $("#txtMenuCode").val(); },
                                            menuId: function () { return $("#hidMenuId").val(); }
                                        }

                                    }).done(function (data) {
                                        //刷新
                                        bol = !data.IsError;

                                    }).fail(function (data) {
                                        bol = true;
                                    });
                                    return bol;
                                }
                            }
                        }

                    }
                }
            });
            $("#cancel").click(function () {
                BMCW.closeTopLayer();
            });
        });


        <%=strMessage %>
    </script>
</body>
</html>
